package com.longge;

public class CarPooling {
    public boolean carPooling(int[][] trips, int capacity) {

        int[] nums = new int[1001];
        Difference difference = new Difference(nums);

        for (int[] trip : trips) {
            int val= trip[0];
            int i = trip[1];
            int j = trip[2]-1;
            difference.increment(i,j,val);
        }
        int[] result = difference.result();
        for (int cap : result) {
            if (cap>capacity) return false;
        }
        return true;
    }

    public static void main(String[] args) {
        new CarPooling().carPooling(new int[][]{{2,1,5},{3,3,7}},4);
    }
}
